package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	BuyerLevelEventNew           = "erp.BuyerLevelNew"
	BuyerLevelEventBeforeCreate  = "erp.BuyerLevelBeforeCreate"
	BuyerLevelEventBeforeUpdate  = "erp.BuyerLevelBeforeUpdate"
	BuyerLevelEventBeforeSave    = "erp.BuyerLevelBeforeCreate erp.BuyerLevelBeforeUpdate"
	BuyerLevelEventAfterCreate   = "erp.BuyerLevelAfterCreate"
	BuyerLevelEventAfterUpdate   = "erp.BuyerLevelAfterUpdate"
	BuyerLevelEventAfterSave     = "erp.BuyerLevelAfterCreate erp.BuyerLevelAfterUpdate"
	BuyerLevelEventDelete        = "erp.BuyerLevelDelete"
	BuyerLevelAccessControlEvent = "erp.BuyerLevelAccessControl"
)

func GetBuyerLevelConfig() *mgo.DocConfig {
	return BuyerLevel_Config
}

var BuyerLevel_Config *mgo.DocConfig

func init() {
	BuyerLevel_Config = NewBuyerLevelConfig()
}
func NewBuyerLevelConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.BuyerLevel",
		Fields: []string{
			"name", "sort", "l", "r", "level", "link", "parent", "children",
		},
		RelationFields: []string{
			"parent", "children",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"parent": {
				Config:     GetBuyerLevelConfig,
				DocName:    "BuyerLevel",
				JoinType:   "O",
				KeyInside:  "parentId",
				KeyOutSide: "id",
			},
			"children": {
				Config:     GetBuyerLevelConfig,
				DocName:    "BuyerLevel",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "parentId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
